<template>
  <div class="execution">
    <basic-container>
      <div class="sw-revenue-daily-report">
        <el-form :inline="true">
          <el-form-item label="盘点日期">
            <span v-if="readonly || this.operationType === 'edit'">{{ reportData.statisticsDate | formatDate }}</span>
            <el-date-picker
              v-else
              v-model="initialStatisticsDate"
              type="month"
              value-format="yyyy-MM"
              placeholder="选择日期"
              @change="statisticsDateSelect"
            >
            </el-date-picker>
          </el-form-item>
          <table class="el-table el-table--border">
            <tr>
              <td class="bold center" width="180"></td>
              <td class="bold center" width="210">规格</td>
              <td class="bold center" width="210">部门配发数量</td>
              <td class="bold center" width="210">站间调配数量</td>
	      <td class="bold center" width="210">上交数量</td>
              <td class="bold center" width="210">数量</td>
              <td class="bold center" width="210">金额合计</td>
              <td class="bold center" width="210">实点数量</td>
              <td class="bold center" width="210">差异数量</td>
              <td class="bold center" width="400">原因</td>
            </tr>
            <tr v-if="readonly">
              <td rowspan="4" class="bold center">
                已使用
              </td>
              <td class="bold center" height="79">2 元</td>
              <td class="center">
                <span>{{ reportData.useTwoDispatchNumber }}</span>
              </td>
	      <td class="center">
                <span>{{ reportData.useTwoDeployNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoDeployCompleteNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoMoney.toFixed(2) }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoCheckNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoDiffNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTwoDiffReason }}</span>
              </td>
            </tr>
            <tr v-if="readonly">
              <td class="bold center" height="79">3 元</td>
              <td class="center">
                <span>{{ reportData.useThreeDispatchNumber }}</span>
              </td>
	      <td class="center">
                <span>{{ reportData.useThreeDeployNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeDeployCompleteNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeMoney.toFixed(2) }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeCheckNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeDiffNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useThreeDiffReason }}</span>
              </td>
            </tr>
            <tr v-if="readonly">
              <td class="bold center" height="79">4 元</td>
              <td class="center">
                <span>{{ reportData.useFourDispatchNumber }}</span>
              </td>
	       <td class="center">
                <span>{{ reportData.useFourDeployNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourDeployCompleteNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourMoney.toFixed(2) }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourCheckNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourDiffNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useFourDiffReason }}</span>
              </td>
            </tr>
            <tr v-if="readonly">
              <td class="bold center" height="79">10 元</td>
              <td class="center">
                <span>{{ reportData.useTenDispatchNumber }}</span>
              </td>
	       <td class="center">
                <span>{{ reportData.useTenDeployNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenDeployCompleteNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenMoney.toFixed(2) }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenCheckNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenDiffNumber }}</span>
              </td>
              <td class="center">
                <span>{{ reportData.useTenDiffReason }}</span>
              </td>
            </tr>
            <tr>
              <td rowspan="4" class="bold center">
                未使用
              </td>
              <td class="bold center" height="79">2 元</td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoDispatchNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoDispatchNumber"
                  :min="0"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleDeployCompleteNumberCalculate($event, 'two')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoDeployNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoDeployNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
	      <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoDeployCompleteNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoDeployCompleteNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseNumberChange($event, 2, 'unuseTwoMoney')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoMoney.toFixed(2) }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoMoney"
                  :step="0"
                  :precision="2"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoCheckNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoCheckNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseCheckNumberChange($event, 'two')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoDiffNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTwoDiffNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTwoDiffReason }}</span>
                <el-input
                  v-else
                  type="textarea"
                  v-model="reportData.unuseTwoDiffReason"
                  placeholder="请输入备注"
                  :disabled="readonly"
                />
              </td>
            </tr>
            <tr>
              <td class="bold center" height="79">3 元</td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeDispatchNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeDispatchNumber"
                  :min="0"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleDeployCompleteNumberCalculate($event, 'three')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeDeployNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeDeployNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
	       <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeDeployCompleteNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeDeployCompleteNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseNumberChange($event, 3, 'unuseThreeMoney')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeMoney.toFixed(2) }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeMoney"
                  :step="0"
                  :precision="2"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeCheckNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeCheckNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseCheckNumberChange($event, 'three')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeDiffNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseThreeDiffNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseThreeDiffReason }}</span>
                <el-input
                  v-else
                  type="textarea"
                  v-model="reportData.unuseThreeDiffReason"
                  placeholder="请输入备注"
                  :disabled="readonly"
                />
              </td>
            </tr>
            <tr>
              <td class="bold center" height="79">4 元</td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourDispatchNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourDispatchNumber"
                  :min="0"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleDeployCompleteNumberCalculate($event, 'four')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourDeployNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourDeployNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
	      <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourDeployCompleteNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourDeployNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseNumberChange($event, 4, 'unuseFourMoney')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourMoney.toFixed(2) }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourMoney"
                  :step="0"
                  :precision="2"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourCheckNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourCheckNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseCheckNumberChange($event, 'four')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourDiffNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseFourDiffNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseFourDiffReason }}</span>
                <el-input
                  v-else
                  type="textarea"
                  v-model="reportData.unuseFourDiffReason"
                  placeholder="请输入备注"
                  :disabled="readonly"
                />
              </td>
            </tr>
            <tr>
              <td class="bold center" height="79">10 元</td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenDispatchNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenDispatchNumber"
                  :min="0"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleDeployCompleteNumberCalculate($event, 'ten')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenDeployNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenDeployNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
	      <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenDeployCompleteNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenDeployCompleteNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseNumberChange($event, 10, 'unuseTenMoney')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenMoney.toFixed(2) }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenMoney"
                  :step="0"
                  :precision="2"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenCheckNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenCheckNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  @change="handleUnuseCheckNumberChange($event, 'ten')"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenDiffNumber }}</span>
                <el-input-number
                  v-else
                  class="input-number"
                  v-model="reportData.unuseTenDiffNumber"
                  :step="0"
                  :precision="0"
                  :controls="false"
                  :disabled="true"
                />
              </td>
              <td class="center">
                <span v-if="readonly">{{ reportData.unuseTenDiffReason }}</span>
                <el-input
                  v-else
                  type="textarea"
                  v-model="reportData.unuseTenDiffReason"
                  placeholder="请输入备注"
                  :disabled="readonly"
                />
              </td>
            </tr>
            <tr>
              <td class="bold center">备注</td>
              <td colspan="13" class="center" height="79">
                <span v-if="readonly">{{ reportData.otherRemark }}</span>
                <el-input
                  v-else
                  type="textarea"
                  v-model="reportData.otherRemark"
                  placeholder="请输入备注"
                  :disabled="readonly"
                />
              </td>
            </tr>
            <tr>
              <td colspan="3" class="bold center">盘点人</td>
              <td colspan="4" class="center" height="61">
                <span v-if="readonly">{{ reportData.checkPersonName }}</span>
                <el-select
                  v-else
                  v-model="reportData.checkPersonName"
                  placeholder=""
                  style="width: 100%"
                  @change="changeCheckPersonName"
                  clearable
                  filterable
                  :disabled="readonly"
                >
                  <el-option
                    v-for="(item, index) in userNames"
                    :key="index"
                    :label="item.nikename"
                    :value="item.nikename"
                  >
                  </el-option>
                </el-select>
              </td>
              <td colspan="2" class="bold center">盘点人工号</td>
              <td colspan="3" class="center" height="61">
                <span v-if="readonly">{{ reportData.checkPersonJobNo }}</span>
                <el-select
                  v-else
                  v-model="reportData.checkPersonJobNo"
                  placeholder=""
                  style="width: 100%"
                  clearable
                  filterable
                  :disabled="readonly"
                >
                  <el-option
                    v-for="(item, index) in userJobNos"
                    :key="index"
                    :label="item.userCode"
                    :value="item.userCode"
                  >
                  </el-option>
                </el-select>
              </td>
            </tr>
            <tr>
              <td colspan="3" class="bold center">复核人</td>
              <td colspan="4" class="center" height="61">
                <span v-if="readonly">{{ reportData.attendName }}</span>
                <el-select
                  v-else
                  v-model="reportData.attendName"
                  placeholder=""
                  style="width: 100%"
                  @change="changeAttendName"
                  clearable
                  filterable
                  :disabled="readonly"
                >
                  <el-option
                    v-for="(item, index) in userNames"
                    :key="index"
                    :label="item.nikename"
                    :value="item.nikename"
                  >
                  </el-option>
                </el-select>
              </td>
              <td colspan="2" class="bold center">复核人工号</td>
              <td colspan="3" class="center" height="61">
                <span v-if="readonly">{{ reportData.attendJobNo }}</span>
                <el-select
                  v-else
                  v-model="reportData.attendJobNo"
                  placeholder=""
                  style="width: 100%"
                  clearable
                  filterable
                  :disabled="readonly"
                >
                  <el-option
                    v-for="(item, index) in userJobNos"
                    :key="index"
                    :label="item.userCode"
                    :value="item.userCode"
                  >
                  </el-option>
                </el-select>
              </td>
            </tr>
          </table>
          <div class="submit-content">
            <el-button v-if="!readonly" type="primary" size="small" @click="saveOrUpdate">保存</el-button>
            <el-button size="small" @click="handleCancel">取消</el-button>
          </div>
        </el-form>
      </div>
    </basic-container>
  </div>
</template>

<script>
import { dateFormat } from "@/util/date";
import { getSysUserToRevenue } from "@/api/admin/user";
import { saveOrUpdate, getInvoiceXaztCheck, getTypeValue, getPreviousMonthInvoiceXaztCheck } from "@/api/subwaystm/swstinvoicexaztcheck";

export default {
  name: "invoicexaztCheckAdd",
  props: {
    reportData: {
      type: Object,
      default: () => {
        return {};
      }
    },
    operationType: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      dateFormat: dateFormat,
      initialStatisticsDate: '',
      checkDay: '25',
      userNames: [],
      userJobNos: []
    };
  },
  created() {
    this.getPassenger();
    getTypeValue('pettymoney_check_day').then(response => {
      this.checkDay = response.data.data[0].value;
	  });
  },
  mounted () {
    if(this.operationType == 'add'){
        this.initialStatisticsDate = new Date();
        this.statisticsDateSelect(dateFormat(this.initialStatisticsDate).substr(0, 7));
    }
  },
  computed: {
    readonly(){
      return this.operationType === 'view';
    }
  },
  filters: {
    formatDate(value) {
      if (!value) return '';
      // 格式化日期
      return dateFormat(new Date(value)).substr(0, 7);
    }
  },
  methods: {
    // 计算调配完数量
    handleDeployCompleteNumberCalculate(value, field) {
      if (!isNaN(value)) {
        if (field == 'two') {
          this.reportData.unuseTwoDeployCompleteNumber = this.reportData.unuseTwoBalanceNumber + this.reportData.unuseTwoDispatchNumber + this.reportData.unuseTwoDeployNumber;
        } else if (field == 'three') {
          this.reportData.unuseThreeDeployCompleteNumber = this.reportData.unuseThreeBalanceNumber + this.reportData.unuseThreeDispatchNumber + this.reportData.unuseThreeDeployNumber;
        } else if (field == 'four') {
          this.reportData.unuseFourDeployCompleteNumber = this.reportData.unuseFourBalanceNumber + this.reportData.unuseFourDispatchNumber + this.reportData.unuseFourDeployNumber;
        } else if (field == 'ten') {
          this.reportData.unuseTenDeployCompleteNumber = this.reportData.unuseTenBalanceNumber + this.reportData.unuseTenDispatchNumber + this.reportData.unuseTenDeployNumber;
        }
      }
    },
    // 计算金额合计和差异数量
    handleUnuseNumberChange(value, amount, field) {
      if (!isNaN(value)) {
        this.reportData[field] = value * amount;
        if (field == 'unuseTwoMoney') {
          this.reportData.unuseTwoDiffNumber = this.reportData.unuseTwoCheckNumber - value;
        } else if (field == 'unuseThreeMoney') {
          this.reportData.unuseThreeDiffNumber = this.reportData.unuseThreeCheckNumber - value;
        } else if (field == 'unuseFourMoney') {
          this.reportData.unuseFourDiffNumber = this.reportData.unuseFourCheckNumber - value;
        } else if (field == 'unuseTenMoney') {
          this.reportData.unuseTenDiffNumber = this.reportData.unuseTenCheckNumber - value;
        }
      }
    },
    // 计算差异数量
    handleUnuseCheckNumberChange(value, field) {
      if (!isNaN(value)) {
        if (field == 'two') {
          this.reportData.unuseTwoDiffNumber = value - this.reportData.unuseTwoNumber;
        } else if (field == 'three') {
          this.reportData.unuseThreeDiffNumber = value - this.reportData.unuseThreeNumber;
        } else if (field == 'four') {
          this.reportData.unuseFourDiffNumber = value - this.reportData.unuseFourNumber;
        } else if (field == 'ten') {
          this.reportData.unuseTenDiffNumber = value - this.reportData.unuseTenNumber;
        }
      }
    },
    // 设置盘点日期（yyyy-mm-dd）
    statisticsDateSelect(val) {
      this.reportData.statisticsDate = val + '-' + this.checkDay;
      if(this.operationType === 'add'){
        this.getPreviousMonthData(val)
      }
    },
    getPreviousMonthData(val) {
      getPreviousMonthInvoiceXaztCheck(val)
        .then(response => {
          const result = response.data.data;
          if(!result) {
            this.$set(this.reportData, 'unuseTwoBalanceNumber', 0);
            this.$set(this.reportData, 'unuseThreeBalanceNumber', 0);
            this.$set(this.reportData, 'unuseFourBalanceNumber', 0);
            this.$set(this.reportData, 'unuseTenBalanceNumber', 0);
          } else {
          this.$set(this.reportData, 'unuseTwoBalanceNumber', result.unuseTwoBalanceNumber || 0);
          this.$set(this.reportData, 'unuseThreeBalanceNumber', result.unuseThreeBalanceNumber || 0);
          this.$set(this.reportData, 'unuseFourBalanceNumber', result.unuseFourBalanceNumber || 0);
          this.$set(this.reportData, 'unuseTenBalanceNumber', result.unuseTenBalanceNumber || 0);
            this.handleDeployCompleteNumberCalculate(this.reportData.unuseTwoBalanceNumber, 'two');
            this.handleDeployCompleteNumberCalculate(this.reportData.unuseThreeBalanceNumber, 'three');
            this.handleDeployCompleteNumberCalculate(this.reportData.unuseFourBalanceNumber, 'four');
            this.handleDeployCompleteNumberCalculate(this.reportData.unuseTenBalanceNumber, 'ten');
          }
        })
    },
    // 检查本月备用金盘点数据是否存在
    async getInvoiceXaztCheck(){
      let checkData = {};
      await getInvoiceXaztCheck(this.reportData.statisticsDate)
        .then(response => {
          checkData = response.data.data;
        })
      return checkData;
    },
    // 保存
    async saveOrUpdate() {
      if (this.validatenull(this.reportData.statisticsDate)) {
        this.$message.error("盘点日期不能为空！");
        return false;
      }
      if (this.operationType === 'add') {
        const checkData = await this.getInvoiceXaztCheck();
        if(!this.validatenull(checkData)){
          this.$message.error("本月备用金盘点数据已存在，请勿重复录入！");
          return false;
        }
      }
      this.$confirm("确认要保存吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        saveOrUpdate(this.reportData)
          .then((data) => {
            this.$message.success("保存成功");
            this.handleCancel();
          })
          .catch(() => {
            this.$message.error("保存失败！");
          });
      });
    },
    // 取消
    handleCancel() {
      this.$emit('closed');
    },
    // 获取车站人员
    getPassenger() {
      getSysUserToRevenue().then((response) => {
        this.userNames = response.data.data;
        this.userJobNos = response.data.data;
      });
    },
    // 盘点人选择
    changeCheckPersonName(data) {
      var objVal = {};
      this.userJobNos.forEach((val) => {
        if (val.nikename == data) {
          objVal = val;
        }
      });
      this.reportData.checkPersonJobNo = objVal.userCode;
    },
    // 复核人选择
    changeAttendName(data) {
      var objVal = {};
      this.userJobNos.forEach((val) => {
        if (val.nikename == data) {
          objVal = val;
        }
      });
      this.reportData.attendJobNo = objVal.userCode;
    },
  },
};
</script>
<style lang="scss">
.sw-revenue-daily-report {
  .input-number {
    width: 100%;
  }
  table {
    border: #b7babf solid 1px;
    border-top: none;
    width: 100%;
    td {
      padding: 12px 10px;
      border: #b7babf solid 1px;
    }
  }
  .center {
    text-align: center;
  }
  .bold {
    font-weight: bold;
  }
  .submit-content {
    padding-top: 30px;
    text-align: center;
  }
}
</style>
